﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Riel_Gestion
{
    public partial class FrmFiltroDepuracion : Form
    {
        public FrmFiltroDepuracion()
        {
            InitializeComponent();
        }

        private void btnAceptar_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("¿Esta seguro que desea realizar la depuración?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
            if (dialogResult == DialogResult.Yes)
            {
                rielDataSetTableAdapters.VENTATableAdapter ventaAdapter = new Riel_Gestion.rielDataSetTableAdapters.VENTATableAdapter();
                int res = ventaAdapter.DeleteQuery(int.Parse(txtCodCliente.Text), dtpDesde.Value.Date, dtpHasta.Value.Date);

                if (res > 0)
                    MessageBox.Show("Se eliminaron " + res + " registros de ventas del cliente: " + txtCodCliente.Text, "Depuracion", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if(res == 0)
                    MessageBox.Show("No se encontraron ventas para el cliente: " + txtCodCliente.Text, "Depuracion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                this.Close();
            }
            
            
        }

        private void btnCancelar_Click(object sender, EventArgs e)
        {
            this.Close();
        }

       
    }
}
